package ExamSystemClient.managerSystem.studentManagement;

import ExamSystemClient.client.ClientScanner;
import ExamSystemClient.model.Student;

import java.util.List;
import java.util.Scanner;

/**
 * 查找信息
 *
 * @author huangshuxian
 */
public class SearchStudent extends StudentInfoManage {

    public SearchStudent(List<Student> studentInfos) {
        super(studentInfos);
    }

    @Override
    public void operate() {
        //1、提示用户输入需要查询的学号
        System.out.println("请输入需要查询的学生学号：");
        int number = ClientScanner.getScanner().nextInt();
        int index = getIndexByNumber(number);
        if (index >= 0){
            System.out.println("查询到的学生信息：");
            System.out.println(studentInfos.get(index));
        }else{
            System.out.println("输入的学号信息找不到匹配的数据！");
        }
    }

    @Override
    public SearchStudent show() {
        System.out.println("查询学生信息！");
        return this;
    }
}
